﻿@using Abp.Collections.Extensions
@using KelonProud
@using KelonProud.Web.Views
@using KelonProud.Web.Views.Home.Components.SideBarNavMenu
@model SideBarNavMenuViewModel
@{
    var calculateMenuUrl = new Func<string, string>((url) =>
    {
        if (string.IsNullOrEmpty(url))
        {
            return ApplicationPath;
        }

        if (UrlChecker.IsRooted(url))
        {
            return url;
        }

        return ApplicationPath + url;
    });
}

<ul class="sidebar-menu" data-widget="tree">
    @*<li class="active">
        <a href="@Url.Action("UserPanel","Home")">
            <i class="fa fa-home"></i> <span>首页</span>
        </a>
    </li>*@

    @foreach (var menuItem in Model.Items)
    {
        if (menuItem.Items != null && menuItem.Items.Count > 0)
        {
            <li class="treeview">
                <a href="#">
                    @if (menuItem.Image.HasValue())
                    {
                        <i class="fa @menuItem.Image"></i>
                    }
                    else
                    {
                        <i class="fa fa-files-o"></i>
                    }
                    <span>@menuItem.Name</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    @foreach (var menuItem1 in menuItem.Items)
                    {
                        if (menuItem1.Items != null && menuItem1.Items.Count > 0)
                        {
                            <li class="treeview">
                                <a href="#">
                                    @if (menuItem1.Image.HasValue())
                                    {
                                        <i class="fa @menuItem1.Image"></i>
                                    }
                                    else
                                    {
                                        <i class="fa fa-files-o"></i>
                                    }
                                    <span>@menuItem1.Name</span>
                                    <span class="pull-right-container">
                                        <i class="fa fa-angle-left pull-right"></i>
                                    </span>
                                </a>
                                <ul class="treeview-menu">
                                    @foreach (var menuItem2 in menuItem1.Items)
                                    {
                                        <li>
                                            <a href="@menuItem2.ActionUrl" data-code="@menuItem2.Code">
                                                @if (menuItem2.Image.HasValue())
                                                {
                                                    <i class="fa @menuItem.Image"></i>
                                                }
                                                else
                                                {
                                                    <i class="fa fa-files-o"></i>
                                                }
                                                <span>@menuItem2.Name</span>
                                            </a>
                                        </li>
                                    }
                                </ul>
                            </li>
                        }
                        else
                        {
                            <li>
                                <a href="@menuItem1.ActionUrl" data-code="@menuItem1.Code">
                                    @if (menuItem1.Image.HasValue())
                                    {
                                        <i class="fa @menuItem1.Image"></i>
                                    }
                                    else
                                    {
                                        <i class="fa fa-files-o"></i>
                                    }
                                    <span>@menuItem1.Name</span>
                                </a>
                            </li>
                        }
                    }
                </ul>
            </li>
        }
        else
        {
            <li>
                <a href="@menuItem.ActionUrl" data-code="@menuItem.Code">
                    @if (menuItem.Image.HasValue())
                    {
                        <i class="fa @menuItem.Image"></i>
                    }
                    else
                    {
                        <i class="fa fa-files-o"></i>
                    }
                    <span>@menuItem.Name</span>
                </a>
            </li>
        }
    }
</ul>
